package org.sunflower.t.wxpaytest.infrastructure;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author: TanJingyu
 * @create: 2021-09-26 11:31
 **/
@Getter
@Setter
@ConfigurationProperties(prefix = "wx.pay")
public class WxPayV3Properties {
    private Secret secret;
    private Connection connection;

    public void correctBySelf(WxPayV3PropertiesCalibrator calibrator) {
        calibrator.correct(this);
    }

    public void correctBySelf() {
        this.correctBySelf(new WxPayV3PropertiesCalibrator() {});
    }


    @Getter
    @Setter
    public static class Secret {
        /**
         * 商户号
         */
        private String merchantId;
        /**
         * 商户API证书的证书序列号
         */
        private String merchantSerialNumber;
        /**
         * 商户API私钥
         */
        private PrivateKey privateKey;
        /**
         * API v3密钥
         */
        private String apiV3Key;
//        /**
//         * 微信支付平台证书
//         */
//        private String wechatpayCertificates;

        @Getter
        @Setter
        public static class PrivateKey {
            /**
             * 储存方式
             * 0：文件
             * 其他：字符串
             */
            private byte way;
            /**
             * 根据way，表示为私钥文件位置或私钥字符串
             */
            private String content;

            public boolean isFile() {
                return way == 0;
            }
        }
    }

    @Getter
    @Setter
    public static class Connection {
    }

}
